package o;

import androidx.annotation.Nullable;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

final class aml extends amd {
    private static final Pattern ʻ = Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v2\\.exo$", 32);
    private static final Pattern ʼ = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\.v3\\.exo$", 32);
    private static final Pattern ʽ = Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v1\\.exo$", 32);

    public static File ॱ(File file, int i, long j, long j2) {
        return new File(file, i + "." + j + "." + j2 + ".v3.exo");
    }

    public static aml ˎ(String str, long j) {
        return new aml(str, j, -1, -9223372036854775807L, null);
    }

    public static aml ˋ(String str, long j) {
        return new aml(str, j, -1, -9223372036854775807L, null);
    }

    public static aml ॱ(String str, long j, long j2) {
        return new aml(str, j, j2, -9223372036854775807L, null);
    }

    @Nullable
    public static aml ˎ(File file, amk o_amk) {
        File file2;
        CharSequence name = file.getName();
        if (name.endsWith(".v3.exo")) {
            file2 = file;
        } else {
            file2 = ˋ(file, o_amk);
            if (file2 == null) {
                return null;
            }
            name = file2.getName();
        }
        Matcher matcher = ʼ.matcher(name);
        if (!matcher.matches()) {
            return null;
        }
        aml o_aml;
        long length = file2.length();
        String ˏ = o_amk.ˏ(Integer.parseInt(matcher.group(1)));
        if (ˏ == null) {
            o_aml = null;
        } else {
            o_aml = new aml(ˏ, Long.parseLong(matcher.group(2)), length, Long.parseLong(matcher.group(3)), file2);
        }
        return o_aml;
    }

    @Nullable
    private static File ˋ(File file, amk o_amk) {
        String ॱॱ;
        Matcher matcher;
        CharSequence name = file.getName();
        Matcher matcher2 = ʻ.matcher(name);
        if (matcher2.matches()) {
            ॱॱ = anr.ॱॱ(matcher2.group(1));
            if (ॱॱ == null) {
                return null;
            }
            matcher = matcher2;
        } else {
            matcher2 = ʽ.matcher(name);
            if (!matcher2.matches()) {
                return null;
            }
            ॱॱ = matcher2.group(1);
            matcher = matcher2;
        }
        File ॱ = ॱ(file.getParentFile(), o_amk.ˋ(ॱॱ), Long.parseLong(matcher.group(2)), Long.parseLong(matcher.group(3)));
        if (file.renameTo(ॱ)) {
            return ॱ;
        }
        return null;
    }

    private aml(String str, long j, long j2, long j3, @Nullable File file) {
        super(str, j, j2, j3, file);
    }

    public aml ˊ(int i) {
        amm.ˏ(this.ˏ);
        long currentTimeMillis = System.currentTimeMillis();
        return new aml(this.ˎ, this.ॱ, this.ˋ, currentTimeMillis, ॱ(this.ˊ.getParentFile(), i, this.ॱ, currentTimeMillis));
    }
}
